package apibasej.basic.misc;

public class UtilTime {

	
	public static final String getDifTimeNow(long nanoTimeIni){
		long n = System.nanoTime() - nanoTimeIni;
		StringBuilder sb = new StringBuilder();
		sb.append(n);
		while(sb.length()<7) sb.insert(0,'0');
		sb.insert(sb.length()-6,'.');
		//if(sb.length()>10)sb.insert(sb.length()-10,'.');
		sb.append(" mls");
		return sb.toString();
	}
	
	public static final boolean isExceeded(long nanoTimeIni, long maxTimeInMilis){
		if(getDiffMillisNow(nanoTimeIni)>maxTimeInMilis) return true;
		else return false;
	}
	public static final double getDiffMillisNow(long nanoTimeIni){
		return getDiffMillis(nanoTimeIni, System.nanoTime());
	}
	
	public static final double getDiffMillis(long nanoTimeIni, long nanoTimeEnd){
		double n = nanoTimeEnd - nanoTimeIni;
		return n/1000000D; //transforma nano em millis
	}

	//0,000 000 001 [ billionth ]	nanosecond  [ ns ]
	//0,000 001		[ millionth ]	microsecond [ µs ]
	//0,001			[ thousandth ]	millisecond [ ms ]
	
}
